package com.medsys.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Classe para representar paciente.
 * @author Felipe Lauksas
 *
 */

@Entity
@Table(name="pacientes")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Paciente extends Pessoa{
	/**
	 * Construtor padr�o.
	 */
	public Paciente(){
		
	}

	private static final long serialVersionUID = -3613405572895756314L;

	@Column(name="plano_de_saude")
	private String planoDeSaude;

	@OneToMany(mappedBy="paciente")
	private List<Consulta> listCosultas = new ArrayList<Consulta>();
	
	/**
	 * @return the planoDeSaude
	 */
	public String getPlanoDeSaude() {
		return planoDeSaude;
	}

	/**
	 * @param planoDeSaude the planoDeSaude to set
	 */
	public void setPlanoDeSaude(String planoDeSaude) {
		this.planoDeSaude = planoDeSaude;
	}
	/**
	 * 
	 * @return {@link List} com objetos {@link Consulta} do {@link Paciente}.
	 */
	public List<Consulta> getListCosultas() {
		return listCosultas;
	}
/**
 * Configura a lista de {@link Consulta} de um {@link Paciente}.
 * @param listCosultas do tipo {@link List} com objetos {@link Consulta}.
 */
	public void setListCosultas(List<Consulta> listCosultas) {
		this.listCosultas = listCosultas;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((planoDeSaude == null) ? 0 : planoDeSaude.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Paciente other = (Paciente) obj;
		if (planoDeSaude == null) {
			if (other.planoDeSaude != null)
				return false;
		} else if (!planoDeSaude.equals(other.planoDeSaude))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return super.toString()+"Plano De Saude: " + planoDeSaude + "\n";
	}
}
